﻿
window.SearchKey = null;
$.MGJ.CustomerInfo = [];
(function () {
    var _this = $.MGJ.CustomerInfo;
    $.extend($.MGJ.CustomerInfo, {
        MarketManageExecl: function (ele) {
            $("input.AllClickChild:checked").each(function () {
                info.push($(this).attr('ID'));

            });
            if (info.length == 0) {
                $.L.msgError("请选择要导出的数据信息！");
                return
            }
            if (!$(ele).find('.no-result').hasClass('no-result')) {
                window.open(ACTION_URL("MarketManageExecl", "Market") + "?Key=" + info);
            }
            else {
                $.L.msgWarning('导出数据不能为空！')
            }


        },
        //送红包
        Dialog_GiveHongBaoObj: null,
        GiveHongBao: function () {
            var info = [];
            $("input.AllClickChild:checked").each(function () {
                info.push($(this).attr('ID'));
            });
            if (info.length == 0) {
                $.L.msgError("请选择用户！");
                return
            }
            this.Dialog_GiveHongBaoObj = $.L.dialog({
                url: ACTION_URL("GiveHongBao", "Market"),
                title: "送红包",
                width: 550,
                height: 300,
                buttons: {
                    "button_save": {
                        type: 'primary',
                        text: '确认',
                        click: function () {
                            
                            _this.HongBaoOK(info);
                        }
                    },
                    "button_cancel": {
                        type: 'default',
                        text: '取消',
                        click: 'MODALMISS'
                    }
                }
            });
        },
        //送流量
        Dialog_GiveDataObj: null,
        GiveData: function () {

            var info = [];
            $("input.AllClickChild:checked").each(function () {
                info.push($(this).attr('ID'));
            });
            if (info.length == 0) {
                $.L.msgError("请选择用户！");
                return
            }
            this.Dialog_GiveDataObj = $.L.dialog({
                url: ACTION_URL("GiveData", "Market"),
                title: "流量",
                width: 850,
                height: 300,
                buttons: {
                    "button_save": {
                        type: 'primary',
                        text: '确认',
                        click: function () {
                            _this.GiveDataOk(info);

                        }
                    },
                    "button_cancel": {
                        type: 'default',
                        text: '取消',
                        click: 'MODALMISS'
                    }
                }

            });
        },
        // 交易记录
        Dialog_CustomerRecordObj: null,
        Dialog_CustomerRecord: function (obj) {
          var uID=  $(obj).attr("uID");
            this.Dialog_CustomerRecordObj = $.L.dialog({
                url: ACTION_URL("CustomerRecord", "Market")+"?uID="+uID,
                title: "交易记录",
                width: 1100,
                height:450,
                buttons: {
                    //"button_save": {
                    //    type: 'primary',
                    //    text: '保存',
                    //    click: function () {


                    //    }
                    //},
                    
                }
            });
        }
    });

})(jQuery);

(function () {
    var _this = $.MGJ.CustomerInfo;
    $.extend($.MGJ.CustomerInfo, {
        
        //客户信息列表分页   
        Ajax_MarketUserList: function (pageIndex) {
            window.SearchKey = $("#msearch").val();
            $.L.ajaxHandle({
                url: ACTION_URL("MarketUserList", "Market"),
                data: {
                    msearch: window.SearchKey,
                    pageIndex: pageIndex,
                    pageSize: 10
                },
                success: function (response) {
                    console.log(response)
                    $("#MarkeTtable").L_bindingDataList(response);
                }
            });
        },
        Ajax_MarketDealList: function (pageIndex) {
            window.SearchKey = $("#dealMsearch").val();
            $.L.ajaxHandle({
                url: ACTION_URL("MarketList", "Market"),
                data: {
                    msearch: window.SearchKey,
                    pageIndex: pageIndex,
                    pageSize: 20
                },
                success: function (response) {
                  
                    $("#MarkeTtable").L_bindingDataList(response);
                }
            });
        },

        //记录详情分页
        Ajax_UserDealList: function (uid)
        {
     
            $.L.ajaxHandle({
                url: ACTION_URL("GetUserDealList", "Market"),
                data: {
                    msearch: $("#dealMsearch").val(),
                    pageIndex: 1,
                    pageSize: 8,
                    uid: uid
                },
                success: function (response) {
       
                    $("#UserDealtable").L_bindingDataList(response);
                }
            });
        },


        //确认送红包
        HongBaoOK: function (objs) {
            var money = $("#Money").val();
            //var reg = /^[1-9]{1}\d*(\.\d{0,2})?$/;

            //if (!reg.test(money)) {
            //    $.L.msgError("格式不正确！");
            //    return
            //}
            $.L.ajaxHandle({
                url: ACTION_URL("HongBaoOK", "Market") + "?UserIds=" + objs.join(','),
                data:  $("#form1").serialize(),
                success: function (res) {
               
                     if (res) {
                        $.L.msgSuccess("发送成功！");
                        _this.Dialog_GiveHongBaoObj.close();
                        _this.Ajax_MarketUserList(1);
                    }
                    else $.L.msgError("发送失败！");
                }
            });
        },
        //确认送流量
        GiveDataOk: function (objs) {
            var data = $("#LLBPacket").serialize() + '&UserIds=' + objs;
            $.L.ajaxHandle({
                url: ACTION_URL("GiveDataOk", "Market"),
                data: data,
                success: function (res) {

                    if (res == "true") {
                        $.L.msgSuccess("发送成功！");
                        _this.Dialog_GiveHongBaoObj.close();
                        _this.Ajax_MarketUserList(1);
                    }
                    else $.L.msgError(res);
                }
            });
        },
    });
})(jQuery);

(function () {
    var _this = $.MGJ.CustomerInfo;
    $.extend($.MGJ.CustomerInfo, {

        Bin_State: function (txt)
        {
            //状态 0 未抽奖 1未领取  2 领奖成功
            return txt == 0 ? "已扫码" : txt == 1 ? "未领取" : "领奖成功";
        },
        Bin_Base64Nickname: function (txt)
        {
            return decode(txt);
        },
        Bin_Denomination: function (txt)
        {
            return txt <=0 ? "" : txt;
        }
    });
})(jQuery);
